<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('项目明细列表')" />
    <script th:src="@{/ajax/libs/qrcode/qrcode.min.js}"></script>
</head>
<body class="gray-bg">
<div id="ccsQuestionnaireAnswerDiv" class="lc_userManage" style="width: 200px;height: 200px;margin: 0 auto;background: pink;">

</div>
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>名称：</p>
                                <input type="text" name="comName"/>
                            </li>

                            <li>
                                <p>项目类型：</p>

                                <select name="comType">
                                    <option value="">所有</option>
                                    <option value="1">住宅</option>
                                    <option value="2">商业</option>

                                </select>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:community:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:community:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:community:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:community:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:community:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:community:remove')}]];
        var prefix = ctx + "system/community";
        var qrcode = new QRCode(document.getElementById("ccsQuestionnaireAnswerDiv"), {
            width : 200,
            height : 200
        });
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "项目明细",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'comId',
                    title : 'id',
                },
                {
                    field : 'comNo',
                    title : '小区编号'
                },
                {
                    field : 'comName',
                    title : '名称'
                },
                {
                    field : 'comCode',
                    title : '编码'
                },
                {
                    field : 'comDesc',
                    title : '小区描述'
                },
                {
                    field : 'longitude',
                    title : '经度'
                },
                {
                    field : 'latitude',
                    title : '纬度'
                },

                {
                    field : 'comType',
                    title : '类型' ,
                    formatter: function (value) {
                        if (value == '1') {
                            return '住宅';
                        } else if (value == '2') {
                            return '商业';
                        }
                    },

                },
                {
                    field : 'tel',
                    title : '联系电话'
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="makeCode(\'' + row.comId + '\')"><i class="fa fa-edit"></i>生成二维码</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.comId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.comId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function createQrcode(comId){
            var codeurl="http://ccsc.9zhinet.com/mncp/record/records?comId="+comId;

              var  urlc=ctx + "system/community/createCommonQRCode?url="+codeurl;

                $.operate.get(urlc);



        }

        function makeCode(code) {

            var codeurl="http://ccsc.9zhinet.com/mncp/record/records?comId="+code;

            var  urlc=ctx + "system/community/createCommonQRCode?url="+codeurl;
            qrcode.clear();
            ///zt/questionnaire/{questionnaireId}
            var ss = location.origin + urlc;
            qrcode.makeCode(codeurl);
        }

    </script>
</body>
</html>
